﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace WFAExamAuto.SysOperate
{
    public partial class frmExamAutoGuide : Form
    {
        public FrmMain fmain = new FrmMain();
        public frmExamAutoGuide()
        {
            InitializeComponent();
        }

        private void btnNext1_Click(object sender, EventArgs e)
        {
            tabControl1.SelectTab(this.tabPage2);
        }

        private void btnNext2_Click(object sender, EventArgs e)
        {
            tabControl1.SelectTab(tabPage3);
        }

        private void btnPre2_Click(object sender, EventArgs e)
        {
            tabControl1.SelectTab(tabPage1);
        }

        private void btnPre4_Click(object sender, EventArgs e)
        {
            tabControl1.SelectTab(tabPage3);
        }

        private void btnNext4_Click(object sender, EventArgs e)
        {
            tabControl1.SelectTab(tabPage5);
        }

        private void btnPre3_Click(object sender, EventArgs e)
        {
            tabControl1.SelectTab(tabPage2);
        }

        private void btnNext3_Click(object sender, EventArgs e)
        {
            tabControl1.SelectTab(tabPage4);
        }

        private void btnPre5_Click(object sender, EventArgs e)
        {
            tabControl1.SelectTab(tabPage4);
        }

        private void button8_Click(object sender, EventArgs e)
        {
            frmExamPreview fexampre = new frmExamPreview();
            fexampre.fexamauto = this;
            fexampre.ShowDialog();
            this.Close();
        }

        private void cmbSubject_Click(object sender, EventArgs e)
        {
            cmbSubject.DataSource = fmain.cps.Pro_GetAllSubject();
            cmbSubject.DisplayMember = "subject_name";
        }

        private void cmbSubject_SelectedIndexChanged(object sender, EventArgs e)
        {
            dgvQuestionInfo.AutoGenerateColumns = false;
            dgvQuestionInfo.DataSource = fmain.cps.Pro_GetQuestionTypeBySubjectName(cmbSubject.Text);
            dgvQuestionInfo.Columns[0].DataPropertyName = "typeName";
            dgvQuestionInfo.Columns[1].DataPropertyName = "questionNumber";
        }

        private void cmbQuestionType_Click(object sender, EventArgs e)
        {
            cmbQuestionType.DataSource = fmain.cps.Pro_GetQuestionTypeBySubjectName(cmbSubject.Text);
            cmbQuestionType.DisplayMember = "typeName";
        }

        private void cmbQuestionType_SelectedIndexChanged(object sender, EventArgs e)
        {
            dgvQustTypeSet[0,dgvQustTypeSet.Rows.Count-1].Value= cmbQuestionType.Text;
            dgvQustTypeSet[1, dgvQustTypeSet.Rows.Count - 1].Value = fmain.cps.Pro_GetQuestionTypeTotalNumByQuestionType(dgvQustTypeSet[0, dgvQustTypeSet.Rows.Count - 1].Value.ToString(), cmbSubject.Text).Rows[0][0].ToString();
        }
    }
}